package S09.first;

import java.util.Arrays;

import S09.first.Person.SortBy;

public class F01 {

	public static void main(String[] args) {
		Student[] students = {
			new Student("Zhangsan", 18, "ShuiYuan"),
			new Student("Lisi", 20, "HeDa"),
			new Student("WangWu", 22, "ZhengDa"),
		};
		System.out.println("按姓名升序排列：");
		Arrays.sort(students, Person.sortBy(SortBy.Name));
		for (Student student : students) {
			System.out.println("    "+student);
		}
		System.out.println("按姓名降序排列：");
		Arrays.sort(students, Person.sortBy(SortBy.Name).reversed());
		for (Student student : students) {
			System.out.println("    "+student);
		}
		System.out.println("按学校升序排列：");
		Arrays.sort(students, (s1,s2)->s1.getSchool().compareTo(s2.getSchool()));
		for (Student student : students) {
			System.out.println("    "+student);
		}
	}

}
